﻿
using HBase;
using HBase.db;
using hCommand;
using Persistence;
using System;
using System.Collections.Generic;

namespace Api {

    public class CacheSyncTask : ZtTask {
        ISysAuthorityServer sysAuthorityServer = WMSDalFactray.getDal<ISysAuthorityServer>();
         
        protected override bool onlyOneTimeAsync() {
            time = 300;
            return true;
        }

        public override bool excute() {
            if (MyCache.isDirty<DictRes>()) {

               
                var dicts = sysAuthorityServer.GetDicts();
                MyCache.addOver(dicts);
                MyCache.clearDirty<DictRes>();
            }

           
            check<BParam>();
            check<CoreItem>();
            return true;
        }

        void check<T>() where T : class, CacheData {
            if (MyCache.isDirty<T>()) {
                List<T> list = sysAuthorityServer.GetAll<T>();
                MyCache.addOver(list);
                MyCache.clearDirty<T>();
            }

        } 
        

      
         
    }
}
